package mylittleinvestigations.Events;

import java.util.ArrayList;
import mylittleinvestigations.Dialog;
import mylittleinvestigations.DirectNavigationDirection;

public class DialogEventProvider
{
    private static ArrayList<DialogEventListener> listenerList = new ArrayList<DialogEventListener>();
    
    public static void RegisterListener(DialogEventListener listener)
    {
        if (!listenerList.contains(listener))
        {
            listenerList.add(listener);
        }
    }
    
    public static void ClearListener(DialogEventListener listener)
    {
        listenerList.remove(listener);
    }
    
    public static void RaiseSpeakerEmotionChanged(Dialog sender, String newEmotionId)
    {
        for (int i = 0; i < listenerList.size(); i++)
        {
            listenerList.get(i).OnDialogSpeakerEmotionChanged(sender, newEmotionId);
        }
    }
    
    public static void RaiseOtherEmotionChanged(Dialog sender, String newEmotionId)
    {
        for (int i = 0; i < listenerList.size(); i++)
        {
            listenerList.get(i).OnDialogOtherEmotionChanged(sender, newEmotionId);
        }
    }
    
    public static void RaiseNextFrame(Dialog sender)
    {
        for (int i = 0; i < listenerList.size(); i++)
        {
            listenerList.get(i).OnDialogNextFrame(sender);
        }
    }
    
    public static void RaisePlayerDamaged(Dialog sender)
    {
        for (int i = 0; i < listenerList.size(); i++)
        {
            listenerList.get(i).OnDialogPlayerDamaged(sender);
        }
    }
    
    public static void RaiseOpponentDamaged(Dialog sender)
    {
        for (int i = 0; i < listenerList.size(); i++)
        {
            listenerList.get(i).OnDialogOpponentDamaged(sender);
        }
    }
    
    public static void RaiseSpeakerStartedShaking(Dialog sender)
    {
        for (int i = 0; i < listenerList.size(); i++)
        {
            listenerList.get(i).OnDialogSpeakerStartedShaking(sender);
        }
    }
    
    public static void RaiseSpeakerMouthStateChanged(Dialog sender, boolean isMouthOn)
    {
        for (int i = 0; i < listenerList.size(); i++)
        {
            listenerList.get(i).OnDialogSpeakerMouthStateChanged(sender, isMouthOn);
        }
    }
    
    public static void RaiseDirectlyNavigated(Dialog sender, DirectNavigationDirection direction)
    {
        for (int i = 0; i < listenerList.size(); i++)
        {
            listenerList.get(i).OnDialogDirectlyNavigated(sender, direction);
        }
    }
    
    public static void RaisePressForInfoClicked(Dialog sender)
    {
        for (int i = 0; i < listenerList.size(); i++)
        {
            listenerList.get(i).OnDialogPressForInfoClicked(sender);
        }
    }
    
    public static void RaiseUsePartner(Dialog sender)
    {
        for (int i = 0; i < listenerList.size(); i++)
        {
            listenerList.get(i).OnDialogUsePartner(sender);
        }
    }
    
    public static void RaiseEvidencePresented(Dialog sender, String evidenceId)
    {
        for (int i = 0; i < listenerList.size(); i++)
        {
            listenerList.get(i).OnDialogEvidencePresented(sender, evidenceId);
        }
    }
    
    public static void RaiseEndRequested(Dialog sender)
    {
        for (int i = 0; i < listenerList.size(); i++)
        {
            listenerList.get(i).OnDialogEndRequested(sender);
        }
    }
}
